package com.nidu.demo.tenant;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.nidu.demo.tenant.dto.TenantPackageAddCmd;
import com.nidu.demo.tenant.dto.TenantPackageListQry;
import com.nidu.demo.tenant.dto.TenantPackagePageQry;
import com.nidu.demo.tenant.dto.TenantPackageUpdateCmd;
import com.nidu.demo.common.enums.StatusEnum;
import com.nidu.demo.tenant.api.SysTenantPackageService;
import com.nidu.demo.tenant.dto.TenantPackageCO;
import com.nidu.demo.tenant.executor.command.TenantPackageAddCmdExe;
import com.nidu.demo.tenant.executor.command.TenantPackageDeleteCmdExe;
import com.nidu.demo.tenant.executor.command.TenantPackageUpdateCmdExe;
import com.nidu.demo.tenant.executor.query.TenantPackageListQryExe;
import com.nidu.demo.tenant.executor.query.TenantPackagePageQryExe;
import com.nidu.demo.tenant.executor.query.TenantPackageSingleQryExe;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * 租户套餐服务实现类
 *
 * @author auto
 */
@Service
@RequiredArgsConstructor
public class SysTenantPackageServiceImpl implements SysTenantPackageService {

    private final TenantPackageAddCmdExe addCmdExe;
    private final TenantPackageUpdateCmdExe updateCmdExe;
    private final TenantPackageDeleteCmdExe deleteCmdExe;
    private final TenantPackageSingleQryExe singleQryExe;
    private final TenantPackageListQryExe listQryExe;
    private final TenantPackagePageQryExe pageQryExe;

    @Override
    public SingleResponse<TenantPackageCO> add(TenantPackageAddCmd cmd) {
        return addCmdExe.execute(cmd);
    }

    @Override
    public SingleResponse<TenantPackageCO> update(TenantPackageUpdateCmd cmd) {
        return updateCmdExe.execute(cmd);
    }

    @Override
    public Response delete(Long id) {
        return deleteCmdExe.execute(id);
    }

    @Override
    public Response delete(Set<Long> ids) {
        return deleteCmdExe.execute(ids);
    }

    @Override
    public SingleResponse<TenantPackageCO> getById(Long id) {
        return singleQryExe.execute(id);
    }

    @Override
    public SingleResponse<TenantPackageCO> getByName(String name) {
        return singleQryExe.execute(name);
    }

    @Override
    public MultiResponse<TenantPackageCO> list(TenantPackageListQry qry) {
        return listQryExe.execute(qry);
    }

    @Override
    public PageResponse<TenantPackageCO> page(TenantPackagePageQry qry) {
        return pageQryExe.execute(qry);
    }

    @Override
    public Response updateStatus(Long id, StatusEnum status) {
        return updateCmdExe.updateStatus(id, status);
    }
}
